import java.lang.reflect.Method;

public class Test3 {
    public static void main(String[] args) throws Exception{
        Class<?> user = Class.forName("User");
        Method setAge = user.getDeclaredMethod("setAge", int.class);
        Object o = user.newInstance();
        setAge.invoke(o, 18);

        Method getAge = user.getDeclaredMethod("getAge");
        Object invoke = getAge.invoke(o);

        System.out.println(invoke);
    }
}
